package com.ikun.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ikun.dao.VisitorsDao;
import com.ikun.entity.Visitors;
import com.ikun.entity.req.VisitorDTO;
import com.ikun.service.VisitorsService;

@Service
public class VisitorsServiceImpl implements VisitorsService {

    @Autowired
    private VisitorsDao visitorsDao;

    @Override
    public List<VisitorDTO> findAllVisitors(Integer managerId) {
        return visitorsDao.findAllVisitors(managerId);
    }

    @Override
    public List<VisitorDTO> findAllByManagers(String managersName) {
        return visitorsDao.findAllByManagers(managersName);
    }

    @Override
    public String addVisitors(Visitors visitors) {
        int i = visitorsDao.addVisitors(visitors);
        if (i > 0) {
            return "访客预约成功";
        }
        return "访客预约失败";
    }

    @Override
    public String updateStatus(Integer visitorId) {
        return visitorsDao.updateStatus(visitorId) > 0 ? "状态修改成功" : "状态修改失败";
    }
}